
package com.kugou.game.sdk.ui.activity;

import com.kugou.framework.v4.Fragment;
import com.kugou.framework.v4.ViewPager;
import com.kugou.framework.v4.ViewPager.OnPageChangeListener;
import com.kugou.game.sdk.adapter.AppCenterViewPagerAdapter;
import com.kugou.game.sdk.adapter.CommonViewPagerAdapter;
import com.kugou.game.sdk.api.common.ActivityOrientation;
import com.kugou.game.sdk.base.BaseCommonTitleFragmentActivity;
import com.kugou.game.sdk.core.SDKControler;
import com.kugou.game.sdk.statistics.StatCmd;
import com.kugou.game.sdk.statistics.StaticsManager;
import com.kugou.game.sdk.ui.fragment.TakenGiftbagFragment;
import com.kugou.game.sdk.ui.fragment.TotalGiftBagFragment;
import com.kugou.game.sdk.ui.widget.indicator.TabPageIndicator;
import com.kugou.game.sdk.ui.widget.indicator.UnderlinePageIndicatorEx;
import com.kugou.game.sdk.utils.AppUtil;
import com.kugou.game.sdk.utils.Rx;

import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;

import java.util.ArrayList;

/**
 * 描述:礼包页面
 * 
 * @author liux
 * @since 2014-8-16 下午12:43:16
 */
public class GiftBagActivity extends BaseCommonTitleFragmentActivity {

    private ViewPager mViewPager;

    private TabPageIndicator mTabPageIndicator;

    private UnderlinePageIndicatorEx mUnderlinePageIndicatorEx;

    private CommonViewPagerAdapter mPagerAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        int id = Rx.layout.kg_activity_gift_bag_layout;
        if (id != 0) {
            setContentView(id);
            setupViews();
        }
        // 发送统计-进入礼包中心
        StaticsManager.sendCommonStatis(StatCmd.CMD_ENTER_GIFTBAG_CENTER);
    }

    private void setupViews() {
        setCommonTitle("礼包");
        int viewPagerId = Rx.id.kg_appcenter_viewpager;
        if (viewPagerId != 0) {
            mViewPager = (ViewPager) findViewById(viewPagerId);
        }
        mTabPageIndicator = (TabPageIndicator) findViewById(Rx.id.tabindicator);
        mUnderlinePageIndicatorEx = (UnderlinePageIndicatorEx) findViewById(Rx.id.underlineindicator);
        ArrayList<Fragment> fragmentList = new ArrayList<Fragment>();
        fragmentList.add(TotalGiftBagFragment.newInstance());
        fragmentList.add(TakenGiftbagFragment.newInstance());
        mPagerAdapter = new CommonViewPagerAdapter(getSupportFragmentManager());
        mPagerAdapter.setFragments(fragmentList, new String[] {
                "全部", "已领"
        });
        mViewPager.setAdapter(mPagerAdapter);

        mTabPageIndicator.setViewPager(mViewPager);
        mTabPageIndicator.setOnPageChangeListener(mUnderlinePageIndicatorEx);

        if (SDKControler.getActivityOrientation() == ActivityOrientation.LANDSCAPE) {
            mUnderlinePageIndicatorEx.setWidth(4);
        } else {
            mUnderlinePageIndicatorEx.setWidth(-1);
        }
        mUnderlinePageIndicatorEx.setViewPager(mViewPager);
        mUnderlinePageIndicatorEx.setFades(false);

    }

}
